<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>西大网上书城 - 登录</title>
    <style>
        /* 基础样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Microsoft YaHei", sans-serif;
        }

        body {
            /* 浅灰渐变背景，柔和不刺眼 */
            background: linear-gradient(135deg, #f5f7fa 0%, #e4eaf1 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        /* 标题样式 */
        h1 {
            color: #333;
            margin-bottom: 30px;
            font-weight: 600;
            letter-spacing: 1px;
        }

        /* 表单容器 - 卡片式设计 */
        .login-form {
            background-color: white;
            width: 100%;
            max-width: 400px;
            padding: 30px 25px;
            border-radius: 8px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); /* 轻微阴影增加层次 */
        }

        /* 输入组样式 */
        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: inline-block;
            width: 70px; /* 固定标签宽度，对齐更整齐 */
            color: #555;
            font-size: 15px;
        }

        .form-control {
            width: calc(100% - 75px); /* 自适应剩余宽度 */
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 15px;
            transition: border-color 0.2s;
        }

        .form-control:focus {
            outline: none;
            border-color: #66afe9; /* 聚焦时边框变色，提示当前输入项 */
        }

        /* 验证码区域 - 横向排列 */
        .captcha-group {
            display: flex;
            align-items: center;
            gap: 10px; /* 输入框与图片间距 */
        }

        .captcha-group .form-control {
            flex: 1; /* 输入框占剩余空间 */
        }

        .captcha-img {
            width: 120px;
            height: 36px; /* 与输入框高度匹配 */
            border-radius: 4px;
            cursor: pointer; /* 鼠标悬停提示可点击 */
            border: 1px solid #ddd;
        }

        /* 登录按钮 */
        .submit-btn {
            width: 100%;
            padding: 10px;
            background-color: #4285f4;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .submit-btn:hover {
            background-color: #3367d6; /* 悬停时加深颜色，增强交互感 */
        }
    </style>
</head>
<body>
<h1>欢迎访问西大网上书城</h1>

<form class="login-form" action="./login" method="post">
    <div class="form-group">
        <label for="user">用户：</label>
        <input type="text" id="user" name="user" class="form-control" placeholder="请输入用户名" required>
    </div>

    <div class="form-group">
        <label for="pass">密码：</label>
        <input type="password" id="pass" name="pass" class="form-control" placeholder="请输入密码" required>
    </div>

    <div class="form-group captcha-group">
        <label for="code">验证码：</label>
        <input type="text" id="code" name="code" class="form-control" placeholder="请输入验证码" required>
        <!-- 验证码图片添加点击刷新功能 -->
        <img src="./captcha" class="captcha-img" alt="验证码" onclick="this.src='./captcha?'+Math.random()">
    </div>

    <input type="submit" value="登录系统" class="submit-btn">
</form>

<script>
    // 页面加载时自动刷新一次验证码，避免缓存问题
    window.onload = function() {
        const captchaImg = document.querySelector('.captcha-img');
        captchaImg.src = './captcha?timestamp=' + new Date().getTime();
    };
</script>
</body>
</html>